package com.exwave.socialgame;

import com.google.common.base.Predicates;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket oneApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("用户及Wolf")
                .apiInfo(oneApiInfo())
                .select()
                .apis(Predicates.or(
                        RequestHandlerSelectors.basePackage("com.exwave.socialgame.model_user"),
                        RequestHandlerSelectors.basePackage("com.exwave.socialgame.model_wolfgame")))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo oneApiInfo() {
        return new ApiInfoBuilder()
                .title("----- API文档 -----")
                .description("本文档描述了 SocialGame 第一级阶段微服务接口定义\n")
                .version("1.5")
                .contact(new Contact("小柒", "https://blog.ethreal.cn", "exwave@163.com"))
                .build();
    }


    @Bean
    public Docket twoApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("评论社区")
                .apiInfo(twoApiInfo())
                .select()
                .apis(Predicates.or(RequestHandlerSelectors.basePackage("com.exwave.socialgame.model_society"),
                        RequestHandlerSelectors.basePackage("com.exwave.socialgame.model_websocket")))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo twoApiInfo() {
        return new ApiInfoBuilder()
                .title("----- API文档 -----")
                .description("本文档描述了 SocialGame 第二阶段微服务接口定义\n")
                .version("2.0")
                .contact(new Contact("小柒", "https://blog.ethreal.cn", "exwave@163.com"))
                .build();
    }

}
